<html>
<head><meta charset="utf-8"><title>How to typecheck non-local DefId? · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/How.20to.20typecheck.20non-local.20DefId.3F.html">How to typecheck non-local DefId?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="235720807"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/How%20to%20typecheck%20non-local%20DefId%3F/near/235720807" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/How.20to.20typecheck.20non-local.20DefId.3F.html#235720807">(Apr 22 2021 at 17:54)</a>:</h4>
<p>I'm trying to expand this <code>check_main_fn_ty</code> function to support non-local DefId. The current approach is based HIR, which is not available for <code>DefId</code>s that's non-local. What's the proper way to retrieve similar information(function generics and signature) for non-local <code>DefId</code>s?</p>



<a name="235721117"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/How%20to%20typecheck%20non-local%20DefId%3F/near/235721117" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/How.20to.20typecheck.20non-local.20DefId.3F.html#235721117">(Apr 22 2021 at 17:56)</a>:</h4>
<p>are you looking for <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html#method.fn_sig">https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html#method.fn_sig</a> maybe?</p>



<a name="235721133"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/How%20to%20typecheck%20non-local%20DefId%3F/near/235721133" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/How.20to.20typecheck.20non-local.20DefId.3F.html#235721133">(Apr 22 2021 at 17:57)</a>:</h4>
<p>you can't typeck function bodies of non-local functions</p>



<a name="235722510"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/How%20to%20typecheck%20non-local%20DefId%3F/near/235722510" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/How.20to.20typecheck.20non-local.20DefId.3F.html#235722510">(Apr 22 2021 at 18:05)</a>:</h4>
<p>thanks! yes, i think this is what i want.</p>



<a name="235723889"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/How%20to%20typecheck%20non-local%20DefId%3F/near/235723889" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/How.20to.20typecheck.20non-local.20DefId.3F.html#235723889">(Apr 22 2021 at 18:15)</a>:</h4>
<p>Mmm, no, the current implementation has <code>expect_local()</code> in it, and will panic if non-local <code>DefId</code> is passed...</p>



<a name="235723959"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/How%20to%20typecheck%20non-local%20DefId%3F/near/235723959" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/How.20to.20typecheck.20non-local.20DefId.3F.html#235723959">(Apr 22 2021 at 18:15)</a>:</h4>
<p>well, that sounds like a different problem <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span></p>



<a name="235724584"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/How%20to%20typecheck%20non-local%20DefId%3F/near/235724584" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/How.20to.20typecheck.20non-local.20DefId.3F.html#235724584">(Apr 22 2021 at 18:19)</a>:</h4>
<p><code>fn_sig</code> for extern crates is provided by <code>rustc_metadata</code>, so it should work here <a href="https://doc.rust-lang.org/nightly/nightly-rustc/src/rustc_metadata/rmeta/decoder/cstore_impl.rs.html#91-251">https://doc.rust-lang.org/nightly/nightly-rustc/src/rustc_metadata/rmeta/decoder/cstore_impl.rs.html#91-251</a></p>



<a name="235735641"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/How%20to%20typecheck%20non-local%20DefId%3F/near/235735641" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/How.20to.20typecheck.20non-local.20DefId.3F.html#235735641">(Apr 22 2021 at 19:36)</a>:</h4>
<p>Out of curiosity, why do you need to support non-local <code>DefId</code>s?</p>



<a name="235736151"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/How%20to%20typecheck%20non-local%20DefId%3F/near/235736151" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/How.20to.20typecheck.20non-local.20DefId.3F.html#235736151">(Apr 22 2021 at 19:39)</a>:</h4>
<p>for <a href="https://github.com/rust-lang/rust/issues/28937">https://github.com/rust-lang/rust/issues/28937</a></p>



<a name="235777572"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/How%20to%20typecheck%20non-local%20DefId%3F/near/235777572" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/How.20to.20typecheck.20non-local.20DefId.3F.html#235777572">(Apr 23 2021 at 02:30)</a>:</h4>
<p>Thanks! Let me try it out!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>